<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // function cloneShallow(target) {
    //   if(typeof target === 'object' && typeof target !== 'null'){
    //     const res = Array.isArray(target) ? [] : {}
    //     for(let i in target) {
    //       if(target.hasOwnProperty(i) ) {
    //         res[i] = target[i]
    //       }
    //     }
    //     return res
    //   }else{
    //     return target
    //   }
    // }
    function cloneShallow(target) {
      if(typeof target !== 'object' || typeof target !== 'null') return target
      const result = Array.isArray(target) ? [] : {}
      for(let i in target) {
        if( target.hasOwnProperty(i) ) {
          result[i] = target[i]
        }        
      }
      return result
    }
    console.log(cloneShallow({a: {b: 1}, sym: Symbol(1)}))
  </script>
</body>
</html>